<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>注册</title>
</head>
<body>
<h2>注册</h2>
<form id="registerForm">
    <label for="name">用户名:</label>
    <input type="text" id="name" name="name" required>
    <br>
    <label for="password">密码:</label>
    <input type="password" id="password" name="password" required>
    <br>
    <button type="submit">注册</button>
</form>

<p id="registerMessage"></p>

<script>
    document.getElementById('registerForm').addEventListener('submit', function(event) {
        event.preventDefault();

        var name = document.getElementById('name').value;
        var password = document.getElementById('password').value;

        fetch('/member/register', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ name: name, password: password })
        })
            .then(response => response.text())
            .then(data => {
                document.getElementById('registerMessage').innerText = data;
            });
    });
</script>
</body>
</html>
